@extends('front.common.header')

@section('title',$course->name.' - '. $course->organization->name.' - 推荐机构')

@section('head')
    @parent
    @stop

@section('content')
<link href="{{ asset('/css/teaches/recommendcourse.css') }}" rel="stylesheet" type="text/css"  />
<link href="{{ asset('/css/company/jobs.css') }}" rel="stylesheet" type="text/css">
<link href="{{ asset('/css/employ/list.css') }}" rel="stylesheet" type="text/css">
    <div class="recommend-course-body">
        <!-- 导航开始 -->
        <div class="content">
            <div class='top-nav'>
        		<ul>
        			{!! $mianbaoxie !!}
        		</ul>
        	</div>
        </div>
        <!-- 导航结束 -->
        <div class="recommend-course-contain">
            <div class="course-contain-left fl">
                <!-- 课程信息开始 -->
                <div class="course-apply"> 
                    <div class="apply-left fl">
                        <img src="@if(count($course->attachment)>0){{ $course->attachment->url }}@else{{asset('/images/t-nopic.jpg')}}@endif"/>
                    </div>
                    <div class="apply-right fl">
                        <div class='apply-right-title'>
                            <span>{{str_limit($course->name,20)}}</span>
                            @if ($course->score> 0)
                            @for ($i = 1; $i <=($course->score); $i++)
                            <i><img src="{{ asset('/images/front/recommendcourse/star-color.png') }}"/></i>
                            @endfor
                            @endif
                            @if (5-($course->score) > 0)
                            @for ($i = 1; $i <= (5-$course->score); $i++)
                            <i><img src="{{ asset('/images/front/recommendcourse/star.png') }}"/></i>
                            @endfor
                            @endif
                        </div>
                        <ul>
                            <li>课程价格：<span class='apply-right-jg'>
                            @if($course->cost == 0) 电话咨询 @else {{ bccomp($course->cost,999999,2) == 1 ? '电话咨询':$course->cost."元"}} @endif</span>
                            </li>
                            <li>课程人气：已有<span class='apply-right-rq'>520</span>人报名</li>
                            <li>开班时间：2015-11-08</li>
                            <li>培训周期：2个月</li>
                        </ul>
                        {{--}}<div class="course-apply-sub">
                            <div class='fl'>立即报名</div>
                            <span class='fl'>已有520人报名</span>
                        </div>   --}}
                    </div>
                </div>
                <!-- 课程信息结束 -->

                <!-- 课程详情开始 -->
                <div class="course-details">
                    <div class="course-name">课程详情</div>
                    <div class="course-details-js" id="lessdesc">
                        {!! str_limit($course->introduction,500) !!}
                    </div>
                    <div class="course-details-js hide" id="moredesc">
                        {!! $course->introduction !!}
                    </div>
                    @if(strlen($course->introduction) > 500)
                    <div class="orgcontent-desc">
                        <p class="text-right"><a href="javascript:void(0)" id="toshowmoreorg"><span class="font-14 color-green">显示完整</span></a></p>
                    </div>
                    @endif
                    <script type="text/javascript">
                        $(function(){
                            $("#toshowmoreorg").click(function(){
                                if($("#moredesc").hasClass('hide')){
                                    $("#moredesc").removeClass('hide');
                                    $("#lessdesc").addClass('hide');
                                    $(this).find('span').html('隐藏');
                                }else{
                                    $("#moredesc").addClass('hide');
                                    $("#lessdesc").removeClass('hide');
                                    $(this).find('span').html('显示完整');
                                }
                            });
                        })
                    </script>
                </div>
                <!-- 课程详情结束 -->

                <!-- 课程评价开始 -->
                <div class="course-evaluate">
                    <div class="evaluate-title">课程评价</div>   
                    <div class="course-evaluate-pj" >
                        <table class='fl'>
                            <tr>
                                <td colspan="3">{{ $course->name }}</td>
                            </tr>
                            <tr></tr>
                            <tr>
                                <td>5星：</td>
                                <td>
                                    <div class='cour-pfdiv fl'> 
                                        <div id='cour-pfbg'>   
                                        </div> 
                                    </div>
                                </td>
                                <td id='cour-pfb'>{{$centum['five']}}</td>
                            </tr>
                            <tr>
                                <td>4星：</td>
                                <td>
                                    <div class='cour-pfdiv fl'> 
                                        <div id='cour-pfbg1'>   
                                        </div> 
                                    </div>
                                </td>
                                <td id='cour-pfb1'>{{$centum['four']}}</td>
                            </tr>
                            <tr>
                                <td>3星：</td>
                                <td>
                                    <div class='cour-pfdiv fl'> 
                                        <div id='cour-pfbg2'>   
                                        </div> 
                                    </div>
                                </td>
                                <td id='cour-pfb2'>{{$centum['three']}}</td>
                            </tr>
                            <tr>
                                <td>2星：</td>
                                <td>
                                    <div class='cour-pfdiv fl'> 
                                        <div id='cour-pfbg3'>   
                                        </div> 
                                    </div>
                                </td>
                                <td id='cour-pfb3'>{{$centum['two']}}</td>
                            </tr>
                            <tr>
                                <td>1星：</td>
                                <td>
                                    <div class='cour-pfdiv fl'> 
                                        <div id='cour-pfbg4'>   
                                        </div> 
                                    </div>
                                </td>
                                <td id='cour-pfb4'>{{$centum['one']}}</td>
                            </tr>
                        </table>
                        <script>
                            $(function(){
                                var width = $("#cour-pfb").text();//获取百分比数值
                                $("#cour-pfbg").css("width",width);//将数值赋值给main的width
                                var width1 = $("#cour-pfb1").text();
                                $("#cour-pfbg1").css("width",width1);
                                var width2 = $("#cour-pfb2").text();
                                $("#cour-pfbg2").css("width",width2);
                                var width3 = $("#cour-pfb3").text();
                                $("#cour-pfbg3").css("width",width3);
                                var width4 = $("#cour-pfb4").text();
                                $("#cour-pfbg4").css("width",width4);
                            });
                        </script>

                        <div class="ursr-evaluate">
                            <p>
                                @if ($course->score> 0)
                                @for ($i = 1; $i <=($course->score); $i++)
                                <i><img src="{{ asset('/images/front/recommendcourse/star-color.png') }}"/></i>
                                @endfor
                                @endif
                                @if (5-($course->score) > 0)
                                @for ($i = 1; $i <= (5-$course->score); $i++)
                                <i><img src="{{ asset('/images/front/recommendcourse/star.png') }}"/></i>
                                @endfor
                                @endif
                                <span class='ursr-evaluate-p'>已有{{count($courpj)}}位用户评价</span>
                            </p>     
                            <div class='evaluate-sub' @if(empty($authuser)) onclick="loginTips()" @else data-toggle="modal" data-target="#myEvaluate" @endif>
                               我要评价
                            </div>
                            <!-- Modal -->
                            <div class="modal fade" id="myEvaluate">
                                <div class="eva-div">
                                    <div class='eva-header'>
                                        <span class='eva-title'>{{str_limit( $course->name,20)}}({{ str_limit($course->organization->name,24) }})</span><span class='close' data-dismiss='modal'><span aria-hidden="true">&times;</span></span>
                                    </div>
                                    <div class='eva-content'>
                                        <div class="pingfenList">
                                          <div class='eva-pingjia fl'>
                                            总体评价：
                                          </div>
                                          <ul class='eva-tupian fl'>
                                            <li>1</li>
                                            <li>2</li>
                                            <li>3</li>
                                            <li>4</li>
                                            <li>5</li>
                                          </ul>
                                        </div>
                                        <div class="pingfenList">
                                          <div class='eva-pingjia fl'>
                                            效果：
                                          </div>
                                          <ul class='eva-tupian fl'>
                                            <li>1</li>
                                            <li>2</li>
                                            <li>3</li>
                                            <li>4</li>
                                            <li>5</li>
                                          </ul>
                                        </div>
                                        <div class="pingfenList">
                                           <div class='eva-pingjia fl'>
                                              师资：
                                           </div>
                                           <ul class='eva-tupian fl'>
                                            <li>1</li>
                                            <li>2</li>
                                            <li>3</li>
                                            <li>4</li>
                                            <li>5</li>
                                           </ul>
                                        </div>
                                        <div class="pingfenList">
                                          <div class='eva-pingjia fl'>
                                            环境：
                                          </div>
                                          <ul class='eva-tupian fl'>
                                            <li>1</li>
                                            <li>2</li>
                                            <li>3</li>
                                            <li>4</li>
                                            <li>5</li>
                                          </ul>
                                        </div>
                                        <div class="pingfenList">
                                          <div class='eva-pingjia fl'>
                                            评价：
                                          </div>
                                          <div class='eva-pjnr fl'>
                                            <textarea id="eva-tupian-content" onfocus="this.value=''; this.onfocus=null;">马上写下您的点评分享给大家哦！</textarea>
                                          </div>

                                        </div>
                                        <div class="pingfenList mt10">
                                          <div class='eva-pingjia fl'>
                                            费用：
                                          </div>
                                          <div class='eva-tupian fl'>
                                            <input id="course-feiyong" name="coursefeiyong" type="text" value="">&nbsp;元
                                          </div>
                                        </div>
                                    </div>
                                    <div class='eva-footer'>
                                        <div id="eva-tupian-sub" class='evaluate-sub'>提交点评</div>
                                    </div>
                                    <script type="text/javascript">
                                        $(function(){
                                            $(".eva-tupian li").on("click",function(){
                                                $(this).addClass("pfxtCur");
                                                $(this).prevAll().addClass("pfxtCur");
                                                $(this).nextAll().removeClass("pfxtCur");
　　                                           });
                                            $(".eva-tupian li").dblclick(function(){
                                                $(".eva-tupian li").removeClass("pfxtCur");
                                            });
                                            $("#eva-tupian-sub").on("click", function () {
                                                var evatupianul = $(".eva-tupian");
                                                var ztpj = evatupianul.eq(0).find(".pfxtCur:last").text();
                                                var xgpj = evatupianul.eq(1).find(".pfxtCur:last").text();
                                                var szpj = evatupianul.eq(2).find(".pfxtCur:last").text();
                                                var hjpj = evatupianul.eq(3).find(".pfxtCur:last").text();
                                                var content=$("#eva-tupian-content").val();
                                                var feiyong = $("input[name=coursefeiyong]").val();
                                                var token = '{{ csrf_token() }}';
                                                $.ajax({
                                                    type:'post',
                                                    cache:'false',
                                                    url:'/comment/push?typeid=2',
                                                    data:'cid='+'{{$course->id}}'+'&content='+content+'&ztpj='+ztpj+'&xgpj='+xgpj+'&szpj='+szpj+'&hjpj='+hjpj+'&feiyong='+feiyong+'&_token='+token,
                                                    dataType:'json',
                                                    success:function(data){
                                                        if(data.status == 'success'){
                                                            var jsonData = data.data;
                                                            var html = ''
                                                            html +='<div class="comment-common" id="comment-common">';
                                                              html +='<div class="comment-user-avatar fl pt10">';
                                                                html +='<img src="'+jsonData.logo+'">';
                                                              html +='</div>';
                                                              html +='<div class="comment-main fl">';
                                                                html +='<div class="comment-content text-left">';
                                                                 html +='<p class="font-20 c3"><span>'+jsonData.username+'</span>&nbsp;';
                                                                  html +='<span>';
                                                                  if(jsonData.score>0){
                                                                    for($i=1;$i<=jsonData.score;$i++){
                                                                      html+='<i><img src="'+jsonData.starcolor+'" /></i>';
                                                                    }
                                                                  }
                                                                  if((5-jsonData.score)>0){
                                                                    for($i=1;$i<=(5-jsonData.score);$i++){
                                                                      html+='<i><img src="'+jsonData.star+'"/></i>';
                                                                    }
                                                                  }
                                                                   html +='</span>';
                                                                  if(jsonData.cost>0){
                                                                   html +='<span>&nbsp;&nbsp;&nbsp;'+jsonData.cost+'&nbsp;元</span>';
                                                                  }
                                                                  html +='</p>';
                                                                  html +='<p class="fs14 c5">'+jsonData.content+'</p>';
                                                                  html +='<div class="fs14 c9 ma0">';
                                                                    html +='<div class="fl">'+jsonData.created_at+'&nbsp;&nbsp;&nbsp;&nbsp;';
                                                                      html +='<a href="javascript:;" onclick="showreply('+jsonData.id+')">回复</a>';
                                                                    html +='</div>';
                                                                    html +='<div class="fr mr15">';
                                                                       html +='<img src="'+jsonData.replyimg+'">&nbsp;';
                                                                       html +='<input type="text" name="totalnum'+jsonData.id+'" value="0">';
                                                                    html +='</div>';
                                                                    html +='<div class="clr"></div>';
                                                                  html +='</div>';
                                                                html +='</div>';
                                                                html +='<div id="comment-reply'+jsonData.id+'" class="comment-reply-form mt20 dn">';
                                                                  html +='<div class="comment-reply-form-b">';
                                                                    html +='<textarea id="comment-reply-content'+jsonData.id+'" class="fl" placeholder="人可以走,留下你的态度"></textarea>';
                                                                    html +='<button type="button" id="submit'+jsonData.id+'" class="fr" onclick="pushScore(\'/comment/push?typeid=2\',\''+jsonData.id+'\',\''+jsonData.u_id+'\',\''+jsonData.c_id+'\',\''+token+'\')">发表回复</button>';
                                                                  html +='</div>';
                                                                html +='</div>';
                                                            html +='<div id="message'+jsonData.id+'" class="commentmsg dn"></div>';
                                                            html +='<div class="comment-child text-left" id="comment-childs'+jsonData.id+'">';
                                                            html +='</div>';
                                                            html +='</div>';
                                                            html +='<div class="clr"></div>';
                                                            html +='</div>';
                                                            $('#myEvaluate').modal('hide');
                                                            $("#itemContainer").prepend(html);
                                                            $(".eva-tupian li").removeClass("pfxtCur");
                                                            $("#eva-tupian-content").val("");
                                                            $("input[name=coursefeiyong]").val("");
                                                            $('#holder').show();
                                                            jPages();
                                                        }else{
                                                            layer.open({title:'提示',content:data.msg});
                                                        }
                                                    },
                                                    error:function(){
                                                        alert("发表失败！");
                                                    }
                                                });
                                            })
　　                                        })
                                    </script>
                                </div>
                            </div>
                        </div>
                    </div>  
                </div>
                <!-- 课程评价结束 -->

                <!-- 全部评论开始-->
                <div class="course-comment">
                    <div class="evaluate-title">全部评论</div>
                    <div id="itemContainer" >
                        @foreach($courpj as $k=>$vo)
                        <div class="comment-common" id="comment-common{{$k}}">
                            <div class="comment-user-avatar fl pt10">
                                <img src="{{$vo->logo}}">
                            </div>
                            <div class="comment-main fl">
                                <div class="comment-content text-left">
                                    <p class="font-20 c3">
                                        <span>{{$vo->user->name}}</span>
                                        <span>
                                        @if ($vo->score> 0)
                                        @for ($i = 1; $i <=($vo->score); $i++)
                                        <i><img src="{{ asset('/images/front/recommendcourse/star-color.png') }}"/></i>
                                        @endfor
                                        @endif
                                        @if (5-($vo->score) > 0)
                                        @for ($i = 1; $i <= (5-$vo->score); $i++)
                                        <i><img src="{{ asset('/images/front/recommendcourse/star.png') }}"/></i>
                                        @endfor
                                        @endif
                                        </span>
                                        <span>&nbsp;&nbsp;&nbsp;{{$vo->cost}}&nbsp;元</span>
                                    </p>
                                    <p class="fs14 c5">{{$vo->content}}</p>
                                    <div class="fs14 c9 ma0">
                                        <div class="fl">
                                            {{$vo->created_at}}&nbsp;&nbsp;&nbsp;&nbsp;
                                            <a href="javascript:;" onclick="showreply({{$vo->id}})">回复</a>
                                        </div>
                                        <div class="fr mr15">
                                            <img src="{{ asset('/images/front/jiuyezhinan/pl.png') }}">
                                            @if(count($vo->childComments)>0)
                                            <input type="text" name="totalnum{{$vo->id}}" value="{{count($vo->childComments)}}" readonly="readonly">
                                            @else
                                            <input type="text" name="totalnum{{$vo->id}}" value="0" readonly="readonly">
                                            @endif
                                        </div>
                                        <div class="clr"></div>
                                    </div>
                                </div>
                                <div id="comment-reply{{$vo->id}}" class="comment-reply-form mt20 dn">
                                    <div class="comment-reply-form-b">
                                        <textarea id="comment-reply-content{{$vo->id}}" class="fl" placeholder="人可以走,留下你的态度"></textarea>
                                        <button type="button" id="submit{{$vo->id}}" class="fr" @if(empty($authuser))onclick="loginTips()" @else onclick="pushScore('/comment/push?typeid=2','{{$vo->id}}','{{$vo->user->id}}','{{$vo->c_id}}','{{ csrf_token() }}')" @endif>发表回复</button>
                                    </div>
                                </div>
                                <div id="message{{$vo->id}}" class="commentmsg dn"></div>
                                <div class="comment-child text-left" id="comment-childs{{$vo->id}}">
                                    @if(count($vo->childComments)>0)
                                    <div class="comment-caret-up"><i class="glyphicon glyphicon-triangle-top"></i></div>
                                    <div class="comment-child-content" id="comment-child-content{{$vo->id}}">
                                        @foreach($vo->childComments as $key=>$zn)
                                        @if($key<3)
                                        <div class="comment-child-content-list" >
                                            <p class="fs18 color-green">{{$zn->user->name}}：</p>
                                            <p class="fs14 c5">{{$zn->content}}</p>
                                        </div>
                                        @endif
                                        @endforeach
                                    </div>
                                    @endif
                                </div>
                            </div>
                            <div class="clr"></div>
                        </div>
                        @endforeach
                    </div>
                    {{-- 分页 --}}
                    <div id="holder" @if(count($courpj)== 0) class="holder dn" @else class="holder" @endif></div>
                    <script>
                       jPages();
                    </script>
            </div>

                <!-- 全部评论结束 -->
            </div>
            <div class="course-contain-right fr">
                <!-- 机构信息 -->
                <div class="ogan-info">
                    <div class="ogan-info-size">机构信息</div>
                    <p class="info-size">
                        <a href="/teaches/organization/{{$course->organization->id}}" target="_self">{{str_limit($course->organization->name,24)}}</a>
                    </p>
                    <div class="ogan-info-head">
                        <div class="sep fl">效果<span class="pf">{{ sprintf("%.1f",$course->effect) }}</span></div>
                        <div class="sepm fl">师资<span class="pf">{{ sprintf("%.1f",$course->teachers) }}</span></div>
                        <div class="sep fl">环境<span class="pf">{{ sprintf("%.1f",$course->environment) }}</span></div>
                    </div>
                    <ul>
                        <li><span>分类：</span>{{ !empty($category)?$category->cat_name:'' }}</li>
                        <li><span>电话：</span>{{ $course->organization->telphone }}</li>
                        <li><span>营业时间：</span>{{ $course->organization->show_at }}</li>
                        <li><span>地址：</span>{{str_limit($course->organization->address,20)}}</li>
                    </ul>
                    <a href="javascript:;" title="{{$course->organization->name}}" onclick="showmap('/tmap?id={{$course->organization->id}}','{{$course->organization->name}}');">
                        <span class="color-green">查看地图</span>
                    </a>
                </div>
                <!-- 热门推荐 -->
                <div class="org-rm-course">
                    <div class="ogan-info-size">热门推荐</div>
                    @foreach($courHots as $courh)
                    <div class="org-cou">
                        <a href="/teaches/orgcourse/{{$courh->id}}" target="_self" ><img src="@if(count($courh->attachment)>0){{ $courh->attachment->url }}@else{{asset('/images/t-nopic.jpg')}}@endif"></a>
                        <div class="jq">{{str_limit($courh->name,22)}}</div>
                        <div class="mf">
                            <span class='course-mf-zt'>
                            @if($courh->cost == 0) 电话咨询 @else {{ bccomp($courh->cost,999999,2) == 1 ? '电话咨询':$courh->cost}} @endif
                            </span>
                            <span>|</span>
                            <span>{{str_limit($courh->organization->name,18)}}</span>
                        </div>
                    </div>
                    @endforeach
                </div>
            </div>
        </div>
    </div>
@stop
